package org.pork.service;

import java.util.List;

import javax.inject.Inject;

import org.apache.log4j.Logger;
import org.pork.criteria.MinutesCriteria;
import org.pork.domain.MinutesReplyVO;
import org.pork.domain.MinutesVO;
import org.pork.mapper.MinutesMapper;
import org.pork.mapper.MinutesReplyMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MinutesService {

	
	@Inject
	MinutesMapper minMapper;
	
	@Inject
	MinutesReplyMapper minReMapper;
	
	Logger logger = Logger.getLogger("MinutesService");
	
	
	public void regist(MinutesVO vo) throws Exception {
		
		logger.info("MinutesService regist.........");
		
		minMapper.create(vo);
	
	}

	
	public MinutesVO view(Integer seqno) throws Exception {
		
		logger.info("MinutesService view..........");
			
		return minMapper.read(seqno);
		
	}

	
	public void remove(Integer seqno) throws Exception {
		
		logger.info("MinutesService remove...........");
		
		minMapper.delete(seqno);
		
	}

	
	public void modify(MinutesVO vo) throws Exception {
		
		logger.info("MinutesService update...........");
		
		minMapper.update(vo);
		
	}
	
	
	public List<MinutesVO> list(MinutesCriteria minCri) throws Exception{
		
		logger.info("MinutesService list..............");
		
		return minMapper.list(minCri);
		
	}
	
	
	public void viewReply(Integer seqno) throws Exception{
		
		logger.info("MinutesService viewReply..............");
		
		minMapper.read(seqno);
		
	}
	
	
	@Transactional
	public void registReply(MinutesReplyVO minReVO) throws Exception{
		
		logger.info("MinutesService registReply..............");
		
		minReMapper.create(minReVO);
		
		minMapper.updateReplyCntPlus(minReVO.getBbsNo());
		
	}
	
	@Transactional
	public void removeReply(MinutesReplyVO minReVO) throws Exception{
		
		logger.info("MinutesService removeReply..............");
		
		minReMapper.delete(minReVO.getReplyNo());
		
		minMapper.updateReplyCntPlus(minReVO.getBbsNo());
		
	}
	
	
	public void modifyReply(MinutesReplyVO minReVO) throws Exception{
		
		logger.info("MinutesService modifyReply..............");
		
		minReMapper.update(minReVO);
		
	}
	
	
	public List<MinutesReplyVO> listReply(Integer Bbsno) throws Exception{
		
		logger.info("MinutesService listReply..............");
		
		return minReMapper.list(Bbsno);
		
	}
	
}























